package com.czy.daishusys.adapter;

import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.czy.daishusys.R;
import com.czy.daishusys.entity.PersonPageItem;

import java.util.List;

/**
 * Created by Raven on 2017/11/23.
 */

public class PersonPageAdapter extends BaseQuickAdapter<PersonPageItem, BaseViewHolder> {

    public PersonPageAdapter(int layoutResId, List data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PersonPageItem item) {
        helper.setImageResource(R.id.iv_img,item.getIconId());
        helper.setText(R.id.tv_name, item.getName());

        TextView tvContent = helper.getView(R.id.tv_content);
        tvContent.setText(item.getContent());
        Drawable arrow_r = null;
        if(item.isHasArrow()) {
            arrow_r = ContextCompat.getDrawable(mContext, R.mipmap.icon_right);
            arrow_r.setBounds(0, 0, arrow_r.getMinimumWidth(), arrow_r.getMinimumHeight());  //此为必须写的
        } else {
            LinearLayout ll_root = helper.getView(R.id.root);
            ll_root.setClickable(false);
        }
        tvContent.setCompoundDrawables(null, null, arrow_r, null);
    }
}
